﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ST.Buz.Base.Entity;
using ST.Buz.Base.Enums;

namespace ST.Buz.Base.Mapping
{
	public partial class Map_Sys_Organization : IEntityTypeConfiguration<Sys_Organization>
	{
		public void Config(EntityTypeBuilder<Sys_Organization> builder)
		{
			builder.HasKey(m => new { m.ID })
				.HasName("PK_Sys_Organization")
				.IsClustered(true);

			builder.HasIndex(m => new { m.Code })
				.HasName("IX_Sys_Organization_Code")
				.IsClustered(false);

			builder.HasIndex(m => new { m.AreaID })
				.HasName("IX_Sys_Organization_AreaID")
				.IsClustered(false);

			builder.Property(e => e.Type)
				.HasDefaultValueSql("((0))")
				//.HasDefaultValueSql("(("+(int)OrganizationType.通用+"))")
				.ValueGeneratedNever();

			builder.Property(e => e.PID)
				.HasDefaultValueSql("((0))")
				.ValueGeneratedNever();

			builder.Property(e => e.AreaID)
				.HasDefaultValueSql("((0))")
				.ValueGeneratedNever();

			builder.Property(e => e.CertificateNo)
				.IsUnicode(false);

			builder.Property(e => e.Code)
				.IsUnicode(false);

			builder.Property(e => e.Fax)
				.IsUnicode(false);

			builder.Property(e => e.EMail)
				.IsUnicode(false);

			builder.Property(e => e.PYCode)
				.IsUnicode(false);

			builder.Property(e => e.ZipCode)
				.IsUnicode(false);

			builder.Property(e => e.Sort)
				.HasDefaultValueSql("((0))")
				.ValueGeneratedNever();

			builder.Property(e => e.StateNow)
				.HasDefaultValueSql("((" + (int)OrganizationState.正常 + "))")
				.ValueGeneratedNever();

			builder.Property(e => e.AddManID)
				.HasDefaultValueSql("((0))")
				.ValueGeneratedNever();

			builder.Property(e => e.AddDate)
				.HasDefaultValueSql("(getdate())")
				.ValueGeneratedNever();
		}
	}
}
